function Stack()
{
  this.data = new Array();
  this.pointer = 0;
  
  this.push = function (value)
  {
    this.data[pointer] = value;
    pointer++;  
  }
  
  this.pop = function ()
  {
    if(pointer == 0)
      throw new Error("Stack empty.");
      
    pointer--;
    return this.data[pointer];
  }
}

function Base_Colours()
{
  this.colours = Array();
   
  this.addColour = function (name,r,g,b,a) 
  {
      if(!a)
      {
        this.colours[name] = 'rgb(' + r + ',' + g + ',' + b + ')';
      } else {
        this.colours[name] = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
      }
      
      return this.getColour(name);
  }
  
  this.getColour = function (name)
  {
    return this.colours[name];
  }  
}

function Base_Images()
{
  this.images = Array();
  
  this.addImage = function (name, src)
  {
    img = new Image();
    img.src = src;
    
    this.images[name] = img;
    
    return this.getImage(name);
  }
  
  this.getImage = function (name)
  {
    return this.images[name];
  }
}

function Base_Canvas(name)
{  
  this.element = document.getElementById(name);
  
  if(this.element.getContext)
  {
    this.context = this.element.getContext('2d');
  } else {
    throw new Error('Canvas ('+name+'): Cannot get Context');
  }
}

function Canvas_Draw(name)
{
  this.inheritFrom = Base_Canvas;
  this.inheritFrom(name);
 
  this.inheritFrom = Base_Colours;
  this.inheritFrom();
  
  this.inheritFrom = Base_Images;
  this.inheritFrom(); 
  
  this.drawRect = function (c,x,y,w,h)
  {
    this.context.fillStyle = c;
    this.context.fillRect(x,y,w,h);
  }
  
  this.drawImage = function (img,x,y,w,h)
  {
    this.context.drawImage(img,x,y,w,h);  
  }
}

function Engine()
{
  
}
